package com.jfsnpm.autoflow;

import org.apache.commons.lang.StringUtils;
import org.snaker.engine.core.Execution;
import org.snaker.engine.entity.Order;
import org.snaker.engine.entity.Process;
import org.snaker.engine.handlers.IHandler;
import org.snaker.jfinal.plugin.SnakerPlugin;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class AutoSetAuthority implements IHandler{
	public void handle(Execution execution) {
		// TODO 自动开通权限
		Order order = execution.getOrder();
		String orderid = order.getId();
		Process process = SnakerPlugin.getEngine().process().getProcessById(order.getProcessId());
		String formpath=process.getInstanceUrl();
		//TODO:暂时用order id作为表单主键，后续需改为从Variable字段获取
		String formid = orderid;
		if(StringUtils.isBlank(formpath)){
			formpath = process.getName();
		}
		Record formdata = Db.findFirst("select * from form_"+formpath+" where id = ?", formid);
		
		
		
	}

}
